package com.example.testing.launchmode;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.example.testing.R;

/**
 * 通过adb shell dumpsys activity查看堆栈信息
 */
public class LaunchmodeActivity extends Activity {
    private static final String TAG = "LaunchmodeActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launchmode);
        findViewById(R.id.btn_standard).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //理论上用非Activity的Context去启动Activity会报错，但是这里却没有报错
                //Intent intent = new Intent(LaunchmodeActivity.this.getApplicationContext(), StandardActivity.class);
                Intent intent = new Intent(LaunchmodeActivity.this, StandardActivity.class);
                startActivity(intent);
            }
        });
        findViewById(R.id.btn_singletop).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(LaunchmodeActivity.this, SingleTopActivity.class);
                startActivity(intent);
            }
        });
        findViewById(R.id.btn_singletask).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(LaunchmodeActivity.this, SingleTaskActivity.class);
                //不起作用
                // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        });
        findViewById(R.id.btn_singleinstance).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(LaunchmodeActivity.this, SingleInstanceActivity.class);
                startActivity(intent);
            }
        });
        findViewById(R.id.btn_taskaffinity).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(LaunchmodeActivity.this, TaskAffinityActivity.class);
                startActivity(intent);
            }
        });
    }
}
